package test.db.table.oracle.type;

import test.db.table.Table;
import test.db.util.DBUtil;

/**
 * @author newbie
 * @since 0.1
 */
public enum PwUserExtensionTable implements Table, ColumnType {
    USER_SID(Column.userSid),
    PUBLIC_CODE(Column.publicCode),
    PASSWD_QUESTION(Column.passwdQuestion),
    PASSWD_ANSWER(Column.passwdAnswer),
    SSN(Column.ssn),
    ZIP_CODE(Column.zipCode),
    ADDRESS(Column.address),
    BIRTH_DATE(Column.birthDate),
    MARRY_DATE(Column.marryDate),
    EMAIL_YN(Column.emailYn),
    HOMEPAGE(Column.homepage),
    TEL(Column.tel),
    MOBILE(Column.mobile),
    POINT(Column.point),
    HOBBY_CODE(Column.hobbyCode),
    COMMENT(Column.comment),
    CERTIFY_NO(Column.certifyNo),
    REGIST_DATE(Column.registDate),
    REGIST_TIME(Column.registTime),
    MODIFY_DATE(Column.modifyDate),
    MODIFY_TIME(Column.modifyTime);
    
    private final Column column;
    private static final String TYPE_PUBLIC_CODE = "VARCHAR2(12)";
    private static final String TYPE_PASSWD_QUESTION = "VARCHAR2(255)";
    private static final String TYPE_PASSWD_ANSWER = "VARCHAR2(255)";
    private static final String TYPE_SSN = "VARCHAR2(13)";
    private static final String TYPE_ZIP_CODE = "VARCHAR2(6)";
    private static final String TYPE_ADDRESS = "VARCHAR2(255)";
    private static final String TYPE_BIRTH_DATE = "VARCHAR2(8)";
    private static final String TYPE_MARRY_DATE = "VARCHAR2(8)";
    private static final String TYPE_EMAIL_YN = "CHAR(1)";
    private static final String TYPE_HOMEPAGE = "VARCHAR2(255)";
    private static final String TYPE_TEL = "VARCHAR2(20)";
    private static final String TYPE_MOBILE = "VARCHAR2(20)";
    private static final String TYPE_POINT = "NUMBER(12)";
    private static final String TYPE_HOBBY_CODE = "VARCHAR2(12)";
    private static final String TYPE_COMMENT = "VARCHAR2(2000)";
    private static final String TYPE_CERTIFY_NO = "VARCHAR2(15)";

    PwUserExtensionTable(Column column) {
        this.column = column;
    }
    
    private enum Column {
        userSid {
            String getType() {
                return TYPE_USER_SID;
            }
        },
        
        publicCode {
            String getType() {
                return TYPE_PUBLIC_CODE;
            }
        },
        
        passwdQuestion {
            String getType() {
                return TYPE_PASSWD_QUESTION;
            }
        },
        
        passwdAnswer {
            String getType() {
                return TYPE_PASSWD_ANSWER;
            }
        },
        
        ssn {
            String getType() {
                return TYPE_SSN;
            }
        },
        
        zipCode {
            String getType() {
                return TYPE_ZIP_CODE;
            }
        },
        
        address {
            String getType() {
                return TYPE_ADDRESS;
            }
        },
        
        birthDate {
            String getType() {
                return TYPE_BIRTH_DATE;
            }
        },
        
        marryDate {
            String getType() {
                return TYPE_MARRY_DATE;
            }
        },
        
        emailYn {
            String getType() {
                return TYPE_EMAIL_YN;
            }
        },
        
        homepage {
            String getType() {
                return TYPE_HOMEPAGE;
            }
        },
        
        tel {
            String getType() {
                return TYPE_TEL;
            }
        },
        
        mobile {
            String getType() {
                return TYPE_MOBILE;
            }
        },
        
        point {
            String getType() {
                return TYPE_POINT;
            }
        },
        
        hobbyCode {
            String getType() {
                return TYPE_HOBBY_CODE;
            }
        },
        
        comment {
            String getType() {
                return TYPE_COMMENT;
            }
        },
        
        certifyNo {
            String getType() {
                return TYPE_CERTIFY_NO;
            }
        },
        
        registDate {
            String getType() {
                return TYPE_REGIST_DATE;
            }
        },
        
        registTime {
            String getType() {
                return TYPE_REGIST_TIME;
            }
        },
        
        modifyDate {
            String getType() {
                return TYPE_MODIFY_DATE;
            }
        },
        
        modifyTime {
            String getType() {
                return TYPE_MODIFY_TIME;
            }
        };
        
        abstract String getType();
    }
    
    public String getType() {
        return column.getType();
    }
    
    public void initData() throws Exception {
        DBUtil.addData("INSERT INTO PW_USER_EXTENSION VALUES ('00000000000000000000', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '20091010', '101010', '20091010', '101010')");
        DBUtil.addData("INSERT INTO PW_USER_EXTENSION VALUES ('20091212121211111111', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '20091010', '101010', '20091010', '101010')");
        DBUtil.addData("INSERT INTO PW_USER_EXTENSION VALUES ('20091212121211111112', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '20091010', '101010', '20091010', '101010')");
    }
}